package com.cgbl.cg.adapter

import androidx.appcompat.widget.AppCompatImageView
import androidx.recyclerview.widget.RecyclerView
import com.cgbl.cg.R
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.robot.base.configs.AppConstants
import com.robot.base.model.ProjectBean
import com.robot.base.util.arouter.ARouterUtil
import com.robot.base.utils.pic.ImageLoaderUtils

class MoreRecommendAdapter :
    BaseQuickAdapter<ProjectBean, BaseViewHolder>(R.layout.app_item_more_recommend) {
    override fun convert(holder: BaseViewHolder, item: ProjectBean) {
        holder.setText(R.id.item_tv_name, item.title)
            .setText(R.id.item_tv_content, item.infoComment)
            .setText(R.id.item_tv_2, "￥${item.budget}")
        holder.itemView.setOnClickListener {
            ARouterUtil.goToActivity(AppConstants.Router.HOME.A_CASE_DETAILS)
        }

        val recyclerView = holder.getView<RecyclerView>(R.id.item_recyclerView)
        val labelAdapter = LabelAdapter()
        recyclerView.apply {
            adapter = labelAdapter
        }

        labelAdapter.setNewInstance(item.itemLabel?.split(",") as MutableList<String>?)

        val ivImg = holder.getView<AppCompatImageView>(R.id.item_iv_img)
        ImageLoaderUtils.displayRound(
            context,
            ivImg,
            if (item.itemCaseFileDOS?.isNotEmpty() == true) {
                item.itemCaseFileDOS?.get(0)?.filePath ?: ""
            } else {
                ""
            },
            10
        )
    }
}

